package com.ph.demo.io;

import java.io.UnsupportedEncodingException;

/**
 * 编码  字符串到字节  默认使用工程的字符集
 */
public class ContentEncode {

    public static void main(String[] args) throws UnsupportedEncodingException {

        String msg = "生命";

        byte[] datas = msg.getBytes();

        System.out.println(datas.length);

        datas = msg.getBytes("UTF-16LE");

        System.out.println(datas.length);

        datas = msg.getBytes("GBK");

        System.out.println(datas.length);
    }

}
